package com.company.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;

import com.company.project.entity.EJkzTjxxEntity;
import com.company.project.service.EJkzTjxxService;

import javax.annotation.Resource;


/**
 * 健康证体检信息
 *
 * @author liuhui

 * @date 2020-11-13 15:51:12
 */
@Api(tags = "体检信息")
@RestController
@RequestMapping("/jkz/tjxx")
public class EJkzTjxxController {
    @Resource
    private EJkzTjxxService eJkzTjxxService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/eJkzTjxx")
    public String eJkzTjxx() {
        return "ejkztjxx/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("eJkzTjxx/add")
    @RequiresPermissions("eJkzTjxx:add")
    @ResponseBody
    public DataResult add(@RequestBody EJkzTjxxEntity eJkzTjxx){
        eJkzTjxxService.save(eJkzTjxx);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("eJkzTjxx/delete")
    @RequiresPermissions("eJkzTjxx:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        eJkzTjxxService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("eJkzTjxx/update")
    @RequiresPermissions("eJkzTjxx:update")
    @ResponseBody
    public DataResult update(@RequestBody EJkzTjxxEntity eJkzTjxx){
        eJkzTjxxService.updateById(eJkzTjxx);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("eJkzTjxx/listByPage")
    @RequiresPermissions("eJkzTjxx:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody EJkzTjxxEntity eJkzTjxx){
        Page page = new Page(eJkzTjxx.getPage(), eJkzTjxx.getLimit());
        LambdaQueryWrapper<EJkzTjxxEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(EJkzTjxxEntity::getId, eJkzTjxx.getId());
        IPage<EJkzTjxxEntity> iPage = eJkzTjxxService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
